﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace StockShark.Models
{
    // walor (papier wartosciowy)
    public class Instrument
    {
        public int Id { get; set; }
        [Required]
        [StringLength(64)]
        public string Name { get; set; }
        [Required]
        [StringLength(16)]
        public string Acronym { get; set; }
        public decimal CurrentPrice { get; set; }
        public decimal ReferencePrice { get; set; }
        [StringLength(1024)]
        public string Description { get; set; }
        [StringLength(1024)]
        [DataType(DataType.Url)]
        public string WebLink { get; set; }
        [Required]
        [StringLength(64)]
        public string Market { get; set; }

        public decimal Change
        {
            get
            {
                return CurrentPrice - ReferencePrice;
            }
        }

        public decimal ChangePercent
        {
            get
            {
                if (ReferencePrice == 0)
                    return 0;
                return Change / ReferencePrice * 100;
            }
        }

        public decimal EstimatedPrice
        {
            get
            {
                return CurrentPrice > 0 ? CurrentPrice : ReferencePrice;
            }
        }

        public virtual string TypePL
        {
            get
            {
                return "Inne";
            }
        }

        public virtual string Unit
        {
            get
            {
                return "";
            }
        }
    }
}